<script>
	// 引入检查更新模块
	import { checkUpdater } from '@/common/checkUpdater'
	
	import Vue from 'vue'
	export default {
		onLaunch: function () {							
			// console.log('App Launch')
			// app打开时先检查是否有更新记录（更新记录会被保存在storage中）
			// 更新记录的内容为 { 更新标记, 安装包位置 }
            
			// 如果存在更新记录，且更新标记（complete=true）则删除上次使用过的安装包，达到存储释放空间的目的
            
            // 如果存在更新记录，且更新标记（complete=false）则进行安装更新 - 2019年3月27日 新增强制更新内容

			// #ifdef APP-PLUS
			plus.screen.lockOrientation('portrait-primary') //竖屏正方向锁定

			const updated = uni.getStorageSync('updated') // 尝试读取storage

			if (updated.completed === true) { // 如果上次刚更新过
				// 删除安装包及安装记录
				console.log('安装记录被删除，更新成功')
				uni.removeSavedFile({ 
					filePath: updated.packgePath,
					success: (res) => {
						uni.removeStorageSync('updated')
					}
				})
			} else if (updated.completed === false) {
				uni.removeStorageSync('updated')
				plus.runtime.install(updated.packgePath, { force: true })
				uni.setStorage({
					key: 'updated',
					data: {
						completed: true,
						packgePath: updated.packgePath
					},
					success: (res) => {
						console.log('成功安装上次的更新，应用需要重启才能继续完成')
					}
				})     				
				uni.showModal({
					title: '提示',
					content: '应用将重启以完成更新',
					showCancel: false,
					complete: () => {
						plus.runtime.restart()
					}
				})
			} else {
				// 检查更新，参数：{ 当前版本号，跳转到更新页面的url11 }
				checkUpdater(this.$current.id, '/pages/updataAPP/updataAPP',this.siteInfo.wxapp_id) 
			}
			// #endif
			
			
			uni.getSystemInfo({
				success: function(e) {
					Vue.prototype.StatusBar = e.statusBarHeight;
					// #ifndef MP
					Vue.prototype._platform = e.platform
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
					};
					// #endif
			
					// #ifdef MP-WEIXIN
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					// #endif		
				}
			})
				
				
		},
		// onShow: function () {
		// 	console.log('App Show')
		// },
		// onHide: function () {
		// 	console.log('App Hide')
		// }
	}
</script>

<style>
	/* common.wxss */
	@import url("/utils/common.scss");

	page {
		background: #f7f7f7;
	}

	.common-header-xian {
		border-top: 1upx solid #eee;
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 100;
	}

	.del {
		text-decoration: line-through;
		padding-left: 10upx;
		color: #999;
	}

	/* 没有更多 */

	.no-more {
		text-align: center;
		color: #737373;
		padding: 10px 0;
	}

	.yoshop-notcont {
		padding: 130upx 100upx;
		box-sizing: border-box;
	}

	.yoshop-notcont .cont {
		display: block;
		text-align: center;
		font-size: 30upx;
		color: #999;
		margin-top: 10upx;
	}

	.yoshop-notcont .iconfont {
		font-size: 150upx;
		color: #ccc;
		text-align: center;
		display: block;
		margin-bottom: 12upx;
	}

	.yoshop-notcont .img {
		width: 200px;
		height: 120px;
		margin: 0 auto;
	}

	.yoshop-notcont .img image {
		width: 100%;
		height: 100%;
	}

	.yoshop-notcont .jump {
		display: block;
		margin: auto;
		margin-top: 20upx;
		width: 180upx;
		line-height: 60upx;
		color: #fff;
		background: #ff5c5c;
		border-radius: 10upx;
		text-align: center;
		font-size: 30upx;
	}

	.bargain-commont-bg {
		background: rgba(0, 0, 0, 0.6);
		position: fixed;
		right: 0;
		left: 0;
		top: 0;
		bottom: 0;
		z-index: 20;
	}

	.selectNumber {
		height: 52upx;
		flex-direction: row;
		border: 1upx solid rgb(231, 231, 231);
		border-radius: 5upx;
		display: inline-block;
	}

	.selectNumber .default {
		width: 60upx;
		height: 52upx;
		float: left;
		line-height: 48upx;
		padding: 0;
		background: #fff;
		color: #444;
		font-size: 40upx;
		border-radius: unset;
	}

	.selectNumber .default-active {
		background: #fbfbfb;
		color: #ddd;
	}

	.selectNumber button:after {
		content: none;
		border: none;
	}

	.selectNumber input {
		float: left;
		width: 40px;
		height: 26px;
		line-height: 26px;
		border-right: 1upx solid #eee;
		border-left: 1upx solid #eee;
		text-align: center;
		font-size: 28upx;
		color: #444;
	}

	/* 返回顶部 */

	.widget-goTop {
		position: fixed;
		bottom: 150upx;
		z-index: 10;
		right: 24upx;
		background: rgba(255, 255, 255, 0.9);
		width: 76upx;
		height: 76upx;
		border-radius: 76upx;
		border: 1upx solid #eee;
	}

	.widget-goTop .icon-fanhuidingbu {
		color: #666;
		display: block;
		text-align: center;
		line-height: 76upx;
		font-size: 32upx;
	}

	@-webkit-keyframes rotate {
		0% {
			transform: rotate(0deg) scale(1);
		}

		100% {
			transform: rotate(360deg) scale(1);
		}
	}

	@keyframes rotate {
		0% {
			transform: rotate(0deg) scale(1);
		}

		100% {
			transform: rotate(360deg) scale(1);
		}
	}

	/* 底线 */

	.title-footer {
		position: relative;
		z-index: 1;
		height: 80upx;
		line-height: 80upx;
		overflow: hidden;
		color: #888;
		text-align: center;
		margin: 0 18upx 0;
	}

	.title-footer .cont {
		background: #f7f7f7;
		padding: 0 12upx;
		font-size: 28upx;
		z-index: 10;
	}

	.title-footer .hr {
		background: #eee;
		height: 1upx;
		border: 0;
		position: absolute;
		left: 10%;
		right: 10%;
		top: 50%;
		margin-top: 1px;
		z-index: -1;
	}

	.slide-image {
		width: 100%;
		height: 100%;
		margin: 0 auto;
		display: block;
	}

	.goods-comment-box .user {
		margin-right: 15upx;
	}

	.goods-comment-box .user_name {
		color: #999;
	}

	.goods-comment-cont {
		font-size: 30upx;
		color: #333;
		margin: 10upx 0;
	}

	/* 底部操作栏 */

	.footer-fixed {
		position: fixed;
		bottom: 0px;
		left: 0px;
		right: 0px;
		display: flex;
		height: 92upx;
		z-index: 11;
		box-shadow: 0 -2px 20px 0 rgba(144, 52, 52, 0.1);
		background: #fff;
	}

	/* 底部操作按钮 */

	.footer-fixed .opt-btn {
		display: flex;
		text-align: center;
		font-size: 30upx;
		width: 100%;
		height: 100%;
		justify-content: center;
		align-items: center;
	}

	.footer-fixed .opt-btn.btn-main {
		background-image: linear-gradient(90deg, #ff387f, #ff2e34);
		color: #fff;
	}

	.footer-fixed .opt-btn.btn-gray {
		background-color: #ccc;
		color: #fff;
	}

	/* 废弃 */

	.order-bt {
		width: 50%;
		/* background: linear-gradient(to right, #fa1e8c 0, #fc1e56 100%); */
		background-image: linear-gradient(90deg, #ff387f, #ff2e34);
		color: #fff;
		text-align: center;
		line-height: 92upx;
		font-size: 30upx;
	}

	.goods-detail-box {
		padding: 0;
		min-height: 150px;
	}

	.com_xing .icon-shoucang {
		padding-right: 6upx;
		color: #ccc;
		font-size: 26upx;
	}

	.com_xing .icon-shoucang.active {
		color: #f4a213;
	}

	.goods-comment-box .left {
		flex: 3;
		position: relative;
	}

	.goods-comment-box .right {
		flex: 3;
	}

	.v-hide {
		display: none !important;
	}

	.v-show {
		display: block !important;
	}

	.flow-checkout-header {
		padding: 28upx 0;
		background: #fff url('') bottom left repeat-x;
		background-size: 120upx auto;
		position: relative;
	}

	.flow-header-left {
		/* flex: 14; */
	}

	.flow-header-right {
		flex: 1;
	}

	.flow-header-right image {
		width: 34upx;
		height: 34upx;
		margin-top: 20upx;
		float: right;
	}

	.flow-checkout-header .flow-checkout-address {
		color: #777;
		margin-top: 6upx;
	}

	.flow-shopList {
		padding: 18upx 0;
	}

	.flow-shopList .flow-list-left {
		margin-right: 20upx;
	}

	.flow-shopList .flow-list-left image {
		width: 200upx;
		height: 200upx;
		border: 1upx solid #eee;
		background: #fff;
	}

	.flow-shopList .flow-list-right .flow-cont {
		font-size: 28upx;
		color: #ff495e;
	}

	.flow-shopList .flow-list-right .small {
		font-size: 26upx;
		color: #777;
	}

	.flow-shopList .flow-list-right .flow-list-cont {
		padding-top: 10upx;
	}

	.flow-fixed-footer {
		position: fixed;
		bottom: 0;
		width: 100%;
		background: #fff;
		border-top: 1px solid #eee;
		z-index: 11;
	}

	/* 共几件商品 */

	.flow-num-box {
		font-size: 28upx;
		color: #777;
		padding: 16upx 24upx;
		text-align: right;
	}

	.flow-all-money {
		padding: 0 24upx;
		color: #444;
	}

	.flow-all-money .flow-all-list {
		font-size: 28upx;
		padding: 20upx 0;
		border-bottom: 1upx solid rgb(248, 248, 248);
	}

	.flow-all-money .flow-all-list:last-child {
		border-bottom: none;
	}

	.flow-all-money .flow-all-list-cont {
		font-size: 28upx;
		padding: 10upx 0;
	}

	.flow-all-money .flow-arrow {
		justify-content: flex-end;
		align-items: center;
	}

	.flow-fixed-footer .chackout-left {
		font-size: 30upx;
		line-height: 92upx;
		color: #777;
		flex: 4;
		padding-left: 12px;
	}

	.flow-fixed-footer .chackout-right {
		font-size: 34upx;
		flex: 2;
	}

	.flow-btn {
		background: linear-gradient(to right, #fa1e8c 0, #fc1e56 100%);
		color: #fff;
		text-align: center;
		line-height: 92upx;
		display: block;
		font-size: 30upx;
	}

	.flow-list .header .shop_name {
		padding-left: 10upx;
		font-size: 30upx;
		color: #333;
	}

	.flow-list .header image {
		width: 34upx;
		height: 37upx;
		position: absolute;
		top: 50%;
		margin-top: -18upx;
		left: 15px;
	}

	.flow-list .header {
		background: #fdf9f9;
		padding: 24upx 0;
		border-top: 1upx solid #eee;
		border-bottom: 1upx solid #eee;
		font-size: 30upx;
		position: relative;
	}

	.flow-list custom-li,
	.addres-list custom-li {
		margin-top: 25upx;
		display: block;
	}

	.flow-list custom-li:first-child,
	.addres-list custom-li:first-child {
		margin-top: 0;
	}

	.flow-distribution-right .icon-xiangyoujiantou {
		font-size: 26upx;
		position: absolute;
		right: 15px;
		top: 50%;
		margin-top: -16upx;
		color: #999;
	}

	.flow-checkout-address text {
		padding-right: 5upx;
	}

	.flow-header-right .icon-xiangyoujiantou {
		position: absolute;
		right: 15px;
		top: 50%;
		margin-top: -13upx;
		font-size: 32upx;
		color: #999;
	}

	.flow-shopList .flow-list-left image {
		width: 180upx;
		height: 180upx;
	}

	.profile-btn button {
		background: linear-gradient(to right, #fa1e8c 0, #fc1e56 100%);
		color: white;
		margin-bottom: 20upx;
	}

	.flow-checkout-header .icon-dingwei {
		position: absolute;
		top: 50%;
		left: 15px;
		font-size: 40upx;
		color: #777;
		margin-top: -20upx;
	}

	.index-cont-search {
		width: 100%;
		font-size: 28upx;
		position: relative;
		background: #f7f7f7;
	}

	.index-cont-search icon {
		position: absolute;
		left: 50%;
		margin-left: -70upx;
		top: 50%;
		margin-top: -15upx;
	}

	.index-cont-search text {
		margin-left: 72upx;
	}

	@-webkit-keyframes shop {
		0% {
			transform: translateY(-80px);
		}

		50% {
			transform: translateY(0px);
		}

		100% {
			transform: translateY(-80px);
		}
	}

	@keyframes shop {
		0% {
			transform: translateY(-80px);
		}

		50% {
			transform: translateY(0px);
		}

		100% {
			transform: translateY(-80px);
		}
	}

	.user-orderJtou {
		color: #777;
		font-size: 26upx;
	}

	.address-box .left-name {
		width: 95px;
	}

	.address-box .right-cont {
		font-size: 30upx;
		color: #444;
	}

	.address-box .right-cont input {
		width: 100%;
		font-size: 30upx;
		color: #444;
	}

	.address-cont-box picker {
		display: inline-block;
		margin-right: 15px;
		width: 100%;
	}

	.button {
		border: 1px solid #1aad19;
		border-radius: 2px;
	}

	.picker {
		padding: 13px;
		background-color: #fff;
	}

	.profile-list {
		padding: 24upx 0;
		border-bottom: 1px solid #f6f6f9;
	}

	.profile-list .admin {
		font-size: 30upx;
		color: #333;
	}

	.profile-btn button {
		font-size: 34upx;
	}

	.profile-btn button[disabled] {
		background: #f16474;
		color: white;
	}

	.btn-green button {
		background: #1aad19;
		color: white;
	}

	.btn-green button[disabled] {
		background: #9de49c;
		color: white;
	}

	.search-box .left {
		width: 28px;
	}

	.search-box .left icon {
		padding: 18upx;
	}

	.search-box .right {
		flex: 1;
	}

	.xEmojiView {
		margin: 15upx 0;
	}
</style>
